//
//  TOWelcomeViewController.m
//  B段项目
//
//  Created by dllo on 15/12/22.
//  Copyright © 2015年 张智超. All rights reserved.
//

#import "TOWelcomeViewController.h"
#import "HLJSeletionViewController.h"
@interface TOWelcomeViewController ()<UIScrollViewDelegate>

@property(nonatomic, retain)UIScrollView *welcomeScrollView;
@property(nonatomic, retain)UIScrollView *smallScrollView;
@property(nonatomic, retain)UIImageView *imageView;
@property(nonatomic, retain)UINavigationController *mainNaVC;
@property(nonatomic, retain)LeftSlideViewController *LeftSlideVC;

@end

@implementation TOWelcomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    //隐藏UINavigationController导航栏
    self.navigationController.navigationBarHidden = YES;
    
    NSMutableArray *array = [NSMutableArray arrayWithObjects:
                             @"image2.jpg",
                             @"image3.jpg",
                             @"image4.jpg",
                             nil];
    
    self.welcomeScrollView = [[UIScrollView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
    self.welcomeScrollView.contentSize = CGSizeMake(self.view.frame.size.width * array.count, self.view.frame.size.height - 20);
    //隐藏滑动条
    self.welcomeScrollView.showsHorizontalScrollIndicator = NO;
    //设置按页滑动
    self.welcomeScrollView.pagingEnabled = YES;
    //代理
    self.welcomeScrollView.delegate = self;
    //关闭边界反弹效果
    self.welcomeScrollView.bounces = NO;
    
    [self.view addSubview:self.welcomeScrollView];
    
    
    for (int i = 0; i < array.count; i++) {
        self.smallScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(self.view.frame.size.width * i , 0, self.view.frame.size.width, self.view.frame.size.height)];
        self.smallScrollView.backgroundColor = [UIColor whiteColor];
        [self.welcomeScrollView addSubview:self.smallScrollView];
        
        self.imageView = [[UIImageView alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
        self.imageView.backgroundColor = [UIColor whiteColor];
        self.imageView.image = [UIImage imageNamed:[array objectAtIndex:i]];
        [self.smallScrollView addSubview:self.imageView];
        
    }
    
    //设置按钮加在欢迎页,点击push到首页
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(self.view.frame.size.width * 2 + 95 * WIDTH / 375,HEIGHT - 100 * HEIGHT / 667, 185 * WIDTH / 375, 45 * HEIGHT / 667);
    button.layer.masksToBounds = NO;
    button.layer.cornerRadius = 5;
    button.layer.borderWidth = 3;
    button.layer.borderColor = [UIColor grayColor].CGColor;
    [button setTitle:@"开启全新体验" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.welcomeScrollView addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor clearColor];
}


//发送通知
- (void)buttonAction:(UIButton *)btn{

    [[NSNotificationCenter defaultCenter]postNotificationName:@"changeRootVC" object:nil];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
